package com.bdqn.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bdqn.pojo.Right;
import com.bdqn.pojo.Role;
import com.bdqn.service.IRoleService;
import com.bdqn.service.RightService;
import com.bdqn.service.RoleRepository;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.awt.print.Pageable;
import java.util.List;

@Service
public class IRoleServiceImpl implements IRoleService {

    @Resource
    private RoleRepository roleRepository;

    @Resource
    private RightService rightService;

    @Override
    public List<Role> findAllRoles() {
        return roleRepository.findAll();
    }

    @Override
    public Role saveRole(Role role) {
        return roleRepository.save(role);
    }

    @Override
    public void deleteRoleById(Long roleId) {
        roleRepository.deleteById(roleId);
    }

    @Override
    public void deleteRole(Role role) {
        roleRepository.delete(role);
    }

    @Override
    public Role getRole(Long roleId) {
        return roleRepository.findById(roleId).get();
    }

    @Override
    public Page<Role> findRole(String roleName, Pageable pageable) {
        return roleRepository.findRolesByRoleNameLike("%" + roleName + "%" , pageable);
    }

    @Override
    public List<Right> findRightsByRole(Role role) {
        return null;
    }

    @Override
    public List<Right> findAllRights() {
        return null;
    }
}
